package crossrun.tool.pdf2img.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.io.File;

import crossrun.tool.pdf2img.view.FileItemView;

public class DirListAdapter extends BaseAdapter {

    Context context;
    File[] files;
    String index;

    public DirListAdapter(Context context, File[] files, String index) {
        this.context = context;
        this.files = files;
        this.index = index;
    }

    @Override
    public int getCount() {
        return files.length;
    }

    @Override
    public Object getItem(int position) {
        return files[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView==null){
            convertView = new FileItemView(context);
        }
        ((FileItemView)convertView).setFile(files[position],index);
        return convertView;
    }
}
